﻿layui.use(['form', 'layedit', 'laydate'], function () {
    var form = layui.form
        , layer = layui.layer
        , layedit = layui.layedit
        , laydate = layui.laydate;
    //监听提交
    form.on('submit(submit)', function (data) {
        $.ajax({
            url: '/User/SetRole',
            type: 'post',
            dataType: 'json',
            data: {
                UserId: $("#UserId").val(), RoleId: $("#RoleId").val(), UserRoleId: $("#UserRoleId").val()
            },
            success: function (d) {
                if (d.code == 0) {
                    if ($("#RoleId").val() === 1) {  // 超级管理设置完成后跳转到登录页
                        window.top.location.href = "../";
                    }
                }
            }
        });
        var index = parent.layer.getFrameIndex(window.name); // 得到索引
        parent.layer.close(index);
        parent.alertMsy();
    });


});
